package com.heima.media.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.media.entity.WmUser;
import com.heima.media.service.IWmUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 自媒体用户信息表 前端控制器
 * </p>
 *
 * @author Wq
 * @since 2022-10-05
 */
@RestController
@RequestMapping("/api/v1/user")
@Api(tags = "自媒体用户信息表接口")
@CrossOrigin
public class WmUserController {

    @Autowired
    private IWmUserService wmUserService;

    /**
     * 新增自媒体用户
     */
    @PostMapping
    @ApiOperation(value = "新增自媒体用户", notes = "新增自媒体用户")
    @ApiImplicitParam(name = "WmUser", value = "user", required = true, dataType = "WmUser")
    public ResponseResult<WmUser> saveUser(@RequestBody WmUser user) {
        return wmUserService.saveUser(user);
    }

    /**
     * 更新自媒体用户
     */
    @PutMapping
    @ApiOperation(value = "修改自媒体用户", notes = "修改自媒体用户")
    @ApiImplicitParam(name = "WmUser", value = "user", required = true, dataType = "WmUser")
    public ResponseResult<WmUser> updateUser(@RequestBody WmUser user) {
        wmUserService.updateById(user);
        return ResponseResult.okResult();
    }


}
